<!DOCTYPE html>
<html>
<head>
    {include file="../application/common/header.html" /}
</head>

<body>
    <div id="final_term_score_reporttb">
        <form id="final_term_score_reportForm" class="m5">
            学期：
            <select class="easyui-combobox" id="termId" name="termId" data-options="width:120,panelHeight:'auto',value:'请选择', editable:false,textField:'学期名称',valueField:'ID',url:'/compent/Util/termList',onSelect:changeTerm"></select>
            <select class="easyui-combobox" name="termType" id="termType">
                <option value="上">上学期</option>
                <option value="下">下学期</option>
            </select>
            <select id="gradeId" name="gradeId" class="easyui-combobox" data-options="width:80,panelHeight:'auto',url:'/compent/Util/gradeNameList',onSelect:changeGrade"></select>
            <select id="clazz" name="clazz" class="easyui-combobox" data-options="width:80,editable:false"></select>
            学生姓名：
            <input class="easyui-textbox" type="text" name="studentName" id="studentName">
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-search'" onclick="queryOk('final_term_score_report')">查询</a>
            <a class="easyui-linkbutton l-btn l-btn-small" data-options="iconCls:'icon-clear'" onclick="resetForm('final_term_score_report')">重置</a><br/>
            <div class="mt10">
            <a class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="dgUpdate('final_term_score_report')">修改</a>
            <a class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="dgReject('final_term_score_report')">取消</a>
            <a class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="save('final_term_score_report')">保存</a>
            <a class="easyui-linkbutton" data-options="iconCls:'icon-tip',plain:true" onclick="exportToExcel('final_term_score_report')">下载excel模板</a>
            <a class="easyui-linkbutton" data-options="iconCls:'icon-large-smartart',plain:true" onclick="importExcel('final_term_score_report')">导入</a>
        </div>
        </form>
    </div>
    <table id="final_term_score_reportdg">
        <thead frozen="true">
            <tr>
                <th data-options="field:'ID',checkbox:true">ID</th>
                <th data-options="field:'学号',title:'学号'"></th>
                <th data-options="field:'学生姓名',title:'学生姓名'"></th>
            </tr>
        </thead>
        <thead>
            <tr>
                {volist name="list" id="vo"}
                    <th data-options="field:'{$vo}'">{$vo}</th>
                {/volist}
                <th data-options="field:'获奖情况',width:100,formatter(value,row,index) {
                    return '<span class=\'note\' title=\''+row.获奖情况+'\'>'+ row.获奖情况 + '</span>';
                }">获奖情况</th>
                <th data-options="field:'评语',width:100,formatter(value,row,index) {
                    return '<span class=\'note\' title=\''+row.评语+'\'>'+ row.评语 + '</span>';
                }">评语</th>
            </tr>
        </thead>
    </table>
    <div id="uploadBox" style="display: none;height: auto;">
        <div class="m30">
            <form method="post" enctype="multipart/form-data" id="final_term_score_reportUploadForm" action="">
                <div id="scoreTips">
                    
                </div>
                <div class="mt20">
                    <input class="easyui-filebox" data-options="buttonText:'选择文件'" id="files" name="files" style="width:250px;">
                </div>
            </form>
        </div>
        <div class="tnc m20">
            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="uploadCommit('final_term_score_report')" style="width: 200px;">上传</a>
        </div>
    </div>
    <script type="text/javascript">
        var cf = "final_term_score_report";
        var url = "/studentGrowth/final_term_score_report";
        $(function(){
            initDatagrid("final_term_score_report");
            initGrade("final_term_score_report");
        })
        function initDatagrid() {
            $("#"+cf+"dg").datagrid({
                url: url + "/pageQuery.html",
                rownumbers: true,
                striped: true,
                border: false,
                pagination: false,
                pageSize: 30,
                fitColumns: true,
                autoRowHeight: false,
                singleSelect: true,
                fit: true,
                toolbar: "#"+cf+"tb"
            })
        }
        function changeTerm(record){
            var termId = record.value;
            if(!termId) return;
            var termName = record.text;
            var termKey = termName.substr(termName,4);
            var grade = getGrade(termKey,record.value);
            var url="/compent/Util/clazzList?grade="+grade;
            $('#clazz').combobox('setValue','');
            $('#clazz').combobox('reload',url);
        }
        function changeGrade(record){
            var termId = $('#termId').combobox('getValue');
            if(!termId) return;
            var termName = $('#termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var grade = getGrade(termKey,record.value);
            var url="/compent/Util/clazzList?grade="+grade;
            $('#clazz').combobox('setValue','');
            $('#clazz').combobox('reload',url);
        }
        function queryOk(){
            var termId = $('#termId').combobox('getValue');
            var termType = $('#termType').combobox('getValue');
            var termName = $('#termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var gradeId = $('#gradeId').combobox('getValue');
            var grade = getGrade(termKey,gradeId);
            var clazz = $('#clazz').combobox('getValue');
            var studentName = $('#studentName').textbox('getValue');
            if(clazz){
                $('#'+cf+'dg').datagrid('load',{termId:termId,termType:termType,grade:grade,clazz:clazz,studentName:studentName});
            }else{
                $.messager.alert('操作提示','请选择班级。');
            }
        }
        function exportToExcel() {
            var termName = $('#termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var gradeId = $('#gradeId').combobox('getValue');
            var grade = getGrade(termKey,gradeId);
            var clazz = $('#clazz').combobox('getValue');
            window.location.href = url+"/exportExcel.html?grade=" + grade + "&clazz=" + clazz;
        }
        function importExcel() {
            var termId = $('#'+cf+'Form #termId').combobox('getValue');
            var termType = $('#'+cf+'Form #termType').combobox('getValue');
            var termName = $('#'+cf+'Form #termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var gradeId = $('#'+cf+'Form #gradeId').combobox('getValue');
            var gradeName = $('#'+cf+'Form #gradeId').combobox('getText');
            var grade = getGrade(termKey,gradeId);
            var clazz = $('#'+cf+'Form #clazz').combobox('getValue');
            if(termId && clazz){
                $("#scoreTips").html("<span class='calendar-sunday'>确认选择上传" + termName + " "+gradeName+"("+ clazz+")班)成绩，以免成绩上传出错</span>");
                $('#uploadBox').dialog({
                    title : '上传成绩',
                    modal : true,
                    width : 400,
                    top : 100,
                    buttons : '#btns'
                }).show();
            }else{
                $.messager.alert('操作提示','请选择班级。');
            }
        }
        function uploadCommit(){
            var termId = $('#'+cf+'Form #termId').combobox('getValue');
            var termType = $('#'+cf+'Form #termType').combobox('getValue');
            var termName = $('#'+cf+'Form #termId').combobox('getText');
            var termKey = termName.substr(termName,4);
            var gradeId = $('#'+cf+'Form #gradeId').combobox('getValue');
            var grade = getGrade(termKey,gradeId);
            var clazz = $('#'+cf+'Form #clazz').combobox('getValue');
            $.messager.progress({
                title : '提示',
                msg : '上传中，请稍候...'
            });
            $('#'+cf+'UploadForm').form('submit',{
                url: url + "/importExcel.html?termId="+termId+"&termType=" + termType+"&grade="+grade+"&clazz="+clazz,
                success:function(data){
                $.messager.progress('close');
                if(data == '000') {
                    $('#uploadBox').dialog("close");
                    queryOk();
                    $.messager.show({title:'操作提示', msg:"上传成功"});
                    return;
                }
                $.messager.alert('提示', data);
            }})
        }
    </script>

</body>
</html>